import { MockMethod } from 'vite-plugin-mock';
import Mock from 'mockjs';
// 使用方式 fetch('/mock-api/demo/bar', {method: 'get'}); 接口以mock-api开头则表示使用本地mock
// https://github.com/vbenjs/vite-plugin-mock/blob/v2.9.1/README.zh_CN.md

const base = '/mock-api';

export default [
  {
    method: 'get',
    url: base + '/demo/bar',
    response: () => {
      return {
        code: 0,
        data: {
          ...Mock.mock({
            'list|1-100': [
              {
                'index': /S20201228115950[0-9][0-9][0-9]/,
                'pdName': 'Macbook',
                'pdNum': 'p_tmp_60a637cd0d',
                'purchaseNum|1-100': 100,
                'adminName': '财务部111',
                'updateTime': '2020-05-20 @date("HH:mm:ss")',
                'pdType': '电子产品'
              }
            ]
          })
        }
      };
    }
  }
] as MockMethod[];
